package com.gemantic.task.dto;



/**
 * @author xiedi
 * @date 2022/09/15
 **/
public class BaseResponseVo<T> {
    public static final Integer CODE_SUCCESS = 0;
    public static final Integer COMMON_ERROR_CODE = 999999;
    public static final String MSG_SUCCESS = "success";
    private Long timestamp;
    private Integer code;
    private String msg;
    private T data;

    public BaseResponseVo() {
        this.timestamp = System.currentTimeMillis();
        this.code = CODE_SUCCESS;
        this.msg = MSG_SUCCESS;
    }

    public BaseResponseVo(String msg) {
        this();
        this.msg = msg;
    }

    public BaseResponseVo(T data) {
        this();
        this.data = data;
    }

    public BaseResponseVo(int code, String msg) {
        this();
        this.code = code;
        this.msg = msg;
    }

    public BaseResponseVo(int code, String msg, T data) {
        this(code, msg);
        this.data = data;
    }

    public boolean isSuccess() {
        return this.code.equals(CODE_SUCCESS);
    }

    public Long getTimestamp() {
        return this.timestamp;
    }

    public Integer getCode() {
        return this.code;
    }

    public String getMsg() {
        return this.msg;
    }

    public T getData() {
        return this.data;
    }

    public void setTimestamp(final Long timestamp) {
        this.timestamp = timestamp;
    }

    public void setCode(final Integer code) {
        this.code = code;
    }

    public void setMsg(final String msg) {
        this.msg = msg;
    }

    public void setData(final T data) {
        this.data = data;
    }

    protected boolean canEqual(final Object other) {
        return other instanceof BaseResponseVo;
    }


}
